import socket

ss = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
ss.connect(('www.baidu.com',80))
data = "GET {} HTTP/1.1\r\nHost:{}\r\nConnection:close\r\nUser-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36\r\n\r\n".format('/','www.baidu.com').encode('utf8')
ss.send(data)

res = b""
while True:
    tmp_msg = ss.recv(1024)
    res += tmp_msg
    if not tmp_msg:
        break

print(res)